home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / madtrb17.arc / TREK_OBJ.P < prev    next >
Encoding:
Text File  |  1985-09-08  |  13.0 KB  |  375 lines

  1.  
  2. (*
  3. ::::::::::
  4. TREK.OBJ.TEXT
  5. ::::::::::
  6. *)
  7.  
  8. (* overlay *) procedure group(ch:  char);
  9. var
  10.    i: char;
  11.  
  12.    procedure displaylist; forward;
  13.  
  14.    procedure useitem;
  15.    label 10;
  16.    var
  17.       x, y, i:  integer;
  18.       j, index, ch: char;
  19.  
  20.       procedure domachine;
  21.       begin
  22.          case ord(list[index].pts) of
  23.             0:  begin
  24.                 for x:= currx - 10 to currx + 10 do
  25.                    for y:= curry + 5 downto curry - 5 do
  26.                       if ok(x,y) then
  27.                          if universe[x,y].ch in ['X','+'] then
  28.                             universe[x,y].strength:= 0;
  29.                 addscroll('Hey!  All the klingons have');
  30.                 addscroll('lost their power!')
  31.                 end;
  32.             1:  begin
  33.                 addscroll('All the Klingons are immobilized!');
  34.                 nomove:= rand(1,10)
  35.                 end;
  36.             2:  begin
  37.                 addscroll('Internal explosion in the');
  38.                 addscroll('cargo hold!  Systems going');
  39.                 addscroll('          down!');
  40.                 for i:= 1 to 7 do disable(rand(0,500))
  41.                 end;
  42.             3:  begin
  43.                 addscroll('Aliens'' cloaking devices');
  44.                 addscroll('are not working!');
  45.                 seeall:= rand(1,10)
  46.                 end;
  47.             4:  begin
  48.                 addscroll('The crew cannot understand');
  49.                 addscroll('you.  It''s the alien machine,');
  50.                 addscroll('         Captain.');
  51.                 confuse:= rand(1,10)
  52.                 end
  53.             end
  54.       end;
  55.          
  56.       procedure domach2;
  57.       begin
  58.          case ord(list[index].pts) of
  59.             5:  begin
  60.                 for x:= currx - 10 to currx + 10 do
  61.                    for y:= curry + 5 downto curry - 5 do
  62.                       if ok(x,y) then
  63.                          if universe[x,y].ch in ['X','+','R','T','H','A']
  64.                             then universe[x,y].strength:= 0;
  65.                 addscroll('Every alien in the area has');
  66.                 addscroll('lost their power, Captain.')
  67.                 end;
  68.             6:  begin
  69.                 addscroll('Short range scanners have');
  70.                 addscroll('       burnt out!');
  71.                 systems[shortscan]:= rand(0,systems[shortscan])
  72.                 end;
  73.             7:  begin
  74.                 addscroll('Sir! The engines have shut');
  75.                 addscroll('down!  It''s defying all the');
  76.                 addscroll('laws of physics, sir!');
  77.                 if systems[warp] > 75 then systems[warp]:= 75;
  78.                 if systems[impulse] > 75 then systems[impulse]:= 75;
  79.                 systems[warp]:= rand(0,systems[warp]);
  80.                 systems[impulse]:= rand(0,systems[impulse])
  81.                 end;
  82.             8:  begin
  83.                 for x:= currx - 10 to currx + 10 do
  84.                    for y:= curry + 5 downto curry - 5 do
  85.                       if ok(x,y) then
  86.                          if universe[x,y].ch in ['X','+','R','T','H','A']
  87.                             then begin
  88.                            if universe[x,y].ch = '+' then nmbrkling:= 
  89.                                nmbrkling - 1;
  90.                             if universe[x,y].ch in ['+','R','T','H'] then
  91.                                points:= points + ord(universe[x,y].pts);
  92.                             universe[x,y].ch:= ' ';
  93.                             universe[x,y].strength:= 0
  94.                             end;
  95.                 addscroll('Apparently every alien in the');
  96.                 addscroll('area has been destroyed, sir.');
  97.                 addscroll('A very effective weapon!')
  98.                end;
  99.             9:  begin
  100.                 addscroll('Captain! Our torpedos have a');
  101.                 addscroll('    much longer range now!');
  102.                 longer:= rand(5,15)
  103.                 end
  104.             end
  105.       end;
  106.    
  107.       procedure domach3;
  108.       begin
  109.          case ord(list[index].pts) of
  110.             10:  begin
  111.                  systems[computer]:= 100;
  112.                  addln('Computer ')
  113.                  end;
  114.             11:  begin
  115.                  systems[phasers]:= 100;
  116.                  addln('Phasers ')
  117.                  end;
  118.             12:  begin
  119.                 systems[longscan]:= 100;
  120.                  addln('Long-range scanners ')
  121.                  end;
  122.             13:  begin
  123.                  systems[shortscan]:= 100;
  124.                  addln('Short-range scanners ')
  125.                  end;
  126.             14:  begin
  127.                  systems[torpedos]:= 100;
  128.                  addln('Torpedos ')
  129.                  end;
  130.             15:  begin
  131.                  systems[warp]:= 100;
  132.                  addln('Warp-drive engines ')
  133.                  end;
  134.             16:  begin
  135.                  systems[impulse]:= 100;
  136.                  addln('Impulse engies ')
  137.                  end;
  138.             17:  begin
  139.                  nmbrtorps:= nmbrtorps + 10;
  140.                  addscroll('Captain, we''ve got more torpedos!')
  141.                  end;
  142.             18:  begin
  143.                  for x:= currx - 10 to currx + 10 do
  144.                     for y:= curry + 5 downto curry - 5 do
  145.                        if ok(x,y) and ((x > currx + 1) or (x < currx - 1)
  146.                          or (y < curry - 1) or (y > curry + 1)) then
  147.                           if universe[x,y].ch = ' ' then 
  148.                              begin
  149.                              universe[x,y].ch:= ',';
  150.                              universe[x,y].strength:= 0;
  151.                              universe[x,y].pts:= chr(1);
  152.                              end;
  153.                  addscroll('Captain, we have apparently been ');
  154.                  addscroll('surrounded by a field of comets.');
  155.                  scroll;
  156.                  addscroll('Also, our warp engines are out.');
  157.                  systems[warp]:= 45
  158.                  end
  159.           end;
  160.           if ord(list[index].pts) < 17 then addscroll('have gone to 100%!');
  161.         end;
  162.         
  163.         
  164.       begin
  165.       if currlst < 'a' then
  166.          begin
  167.          addscroll('  There''s nothing to use');
  168.          delay(2000);
  169.          goto 10;
  170.          end;
  171.       displaylist;
  172.       clrmesg;
  173.       mesg(3,'   Which item to use?');
  174.       repeat
  175.          read(kbd,ch);
  176.          if ch in ['A'..'Z'] then ch:= chr(ord(ch) + 32)
  177.       until (ch >= 'a') and (ch <= currlst);
  178.       index:= ch;
  179.       clearscroll;
  180.       case list[index].ch of
  181.         ':':  begin
  182.               addscroll('Power levels coming up, Captain');
  183.               totalpower:= totalpower + rand(500,5000)
  184.               end;
  185.        'M':  begin
  186.               addscroll('   As it is turned on, the');
  187.               addscroll('machine shimmers and disappears.');
  188.               for i:= 1 to 3 do scroll;
  189.               delay(2000);
  190.               addscroll('-------- Machine ----------');
  191.               if ord(list[index].pts) > 9 then domach3
  192.               else if ord(list[index].pts) > 4 then domach2
  193.               else domachine;
  194.               if length(names[ord(list[index].pts)]) = 0 then
  195.                  begin
  196.                  delay(1000);
  197.                  addscroll('Call it:');
  198.                  addln('=>');
  199.                  togglecursor;
  200.                  readln(names[ord(list[index].pts)]);
  201.                  togglecursor;
  202.                  scroll
  203.                  end
  204.               end;
  205.         ')':  begin
  206.               addscroll('Systems are now shielded sir!');
  207.               syshields:= rand(5,20)
  208.               end;
  209.         ']':  begin
  210.               addscroll('Ship has extra protection now sir!');
  211.               allshields:= rand(5,20)
  212.               end;
  213.         '^':  begin
  214.               for x:= currx - 10 to currx + 10 do
  215.                  for y:= curry + 5 downto curry - 5 do
  216.                     if ok(x,y) then
  217.                       if not (universe[x,y].ch in ['%','/','@','B']) then
  218.                           begin
  219.                           if universe[x,y].ch = '+' then nmbrkling:=
  220.                              nmbrkling - 1;
  221.                           if universe[x,y].ch = '#' then nmbrbases:=
  222.                              nmbrbases - 1;
  223.                           if universe[x,y].ch in ['+','R','T','H'] then
  224.                              points:= points + ord(universe[x,y].pts);
  225.                           universe[x,y].ch:= ' ';
  226.                           universe[x,y].strength:= 0
  227.                           end;
  228.               addscroll('Everything is destroyed sir')
  229.               end
  230.         end;
  231.       delay(2000);
  232.       for j:= index to pred(currlst) do
  233.         list[j]:= list[succ(j)];
  234.       currlst:=pred(currlst);
  235.    10: end;
  236.  
  237.    procedure printitem(item: space);
  238.    begin
  239.       case item.ch of
  240.          ':':  addscroll('Pair of dilithium crystals');
  241.          'M':  begin
  242.                addscroll('An alien machine with strange markings');
  243.                if return then
  244.                    begin
  245.                    addln('   which ');
  246.                    case ord(item.pts) of
  247.                       0:  addscroll('disarms Klingons');
  248.                       1:  addscroll('stops Klingons');
  249.                       2:  addscroll('blows up');
  250.                       3:  addscroll('penetrates a cloaking device');
  251.                       4:  addscroll('causes confusion');
  252.                       5:  addscroll('disarms all aliens');
  253.                       6:  addscroll('destroys short scanners');
  254.                       7:  addscroll('hampers the engines');
  255.                       8:  addscroll('destroys all aliens');
  256.                       9:  addscroll('extends torpedos');
  257.                      10:  addscroll('fixes the computer');
  258.                      11:  addscroll('fixes the phasers');
  259.                      12:  addscroll('fixes the long scanners');
  260.                      13:  addscroll('fixes the short scanners');
  261.                      14:  addscroll('fixes the torpedos');
  262.                      15:  addscroll('fixes the warp drive');
  263.                      16:  addscroll('fixes the impulse engines');
  264.                      17:  addscroll('creates a comet field');
  265.                      18:  addscroll('creates torpedos')
  266.                       end
  267.                    end
  268.                else if length(names[ord(item.pts)]) > 0 then
  269.                    addscroll(concat('  (',names[ord(item.pts)],') '))
  270.                end;
  271.          '^':  addscroll('A super bomb');
  272.          ']':  addscroll('Shields for the ship');
  273.          ')':  addscroll('Shields for systems');
  274.          '/':  addscroll('The Staff of Surak')
  275.          end
  276.    end;
  277.    
  278.    procedure displaylist;
  279.    var
  280.      i: char;
  281.      temp: string80;
  282.    begin
  283.       clearscroll;
  284.       if currlst < 'a' then addscroll(' You have nothing')
  285.       else begin
  286.           addscroll('--------- Cargo -----------');
  287.           for i:= 'a' to currlst do
  288.              begin
  289.              temp:= ' ) ';
  290.              temp[1]:= i;
  291.              addln(temp);
  292.              printitem(list[i])
  293.              end
  294.          end
  295.    end;
  296.    
  297.    procedure drop;
  298.    var
  299.       x, y: integer;
  300.       index, i, ch: char;
  301.    begin
  302.       displaylist;
  303.       if currlst >= 'a' then
  304.          begin
  305.          clrmesg;
  306.          mesg(3,'Which item to drop?');
  307.          repeat
  308.             read(kbd,ch);
  309.             if ch in ['A'..'Z'] then ch:= chr(ord(ch) + 32)
  310.          until (ch >= 'a') and (ch <= currlst);
  311.          clearscroll;
  312.          index:= ch;
  313.          x:= currx;
  314.          y:= curry;
  315.          if ok(x,y) then
  316.             begin
  317.             moveround(x,y);
  318.             universe[x,y]:= list[index];
  319.             printitem(list[index])
  320.             end;
  321.          for i:= index to pred(currlst) do
  322.             list[i]:= list[succ(i)];
  323.          currlst:= pred(currlst);
  324.          addscroll('           dropped');
  325.          delay(2000)
  326.          end
  327.    end;
  328.     
  329.    procedure getitem;
  330.    label 10;
  331.    var
  332.       gotten: boolean;
  333.       x,y: integer;
  334.    begin
  335.      gotten:= false;
  336.      for x:= currx + 1 downto currx - 1 do
  337.        for y:= curry + 1 downto curry - 1 do
  338.          if ok(x,y) then
  339.            if universe[x,y].ch in [':','M','^','/',')',']'] then
  340.              begin
  341.                if currlst < maxlist then
  342.                  begin
  343.                    gotten:= true;
  344.                    currlst:= succ(currlst);
  345.                    list[currlst]:= universe[x,y];
  346.                    universe[x,y].ch:= ' ';
  347.                    universe[x,y].strength:= 0;
  348.                    printitem(list[currlst])
  349.                  end
  350.                else
  351.                  begin
  352.                    if not gotten then addscroll('You cannot carry anymore');
  353.                    goto 10;
  354.                  end
  355.              end;
  356.       if not gotten then addscroll('Nothing to pick up');
  357. 10: end;
  358.  
  359. begin
  360.    return:= false;
  361.    for i:= 'a' to currlst do if list[i].ch = '/' then return:= true;
  362.    case ch of
  363.      'G','g':  getitem;
  364.      'U','u':  useitem;
  365.      'D','d':  drop;
  366.      'W','w':  begin
  367.                displaylist;
  368.                delay(5000)
  369.                end
  370.      end;
  371.    clrmesg
  372. end;
  373.  
  374.  
  375.